package pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author 薛剑
 * @date 2020-11-23 16:19
 */
public class MyThreadpool {
    public static void main(String[] args) {


        //5个处理线程
        ExecutorService threadpoolm = Executors.newFixedThreadPool(5);//一池多个线程
       ExecutorService threadpoolmg = Executors.newSingleThreadExecutor();//一池一个线程
        ExecutorService threadpool = Executors.newCachedThreadPool();//一池N个线程

        //模拟10个用户来办理业务

        try {

            for (int i = 1; i <1150 ; i++) {
                threadpool.execute(()->{

                    System.out.println(Thread.currentThread().getName()+"办理业务");
                });

            }


        } catch (Exception e) {

        }
        finally {
threadpool.shutdown();
        }
    }

}
